package flc.ast;

import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.stark.fcm.base.FcmModule;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.CommunityFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.WallpaperFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
    }

    @Override
    protected void initData() {
        super.initData();
        //防沉迷埋点2
        FcmModule.getInstance().init(this);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        //防沉迷埋点3
        FcmModule.getInstance().onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void onBackPressed() {
        //防沉迷埋点4
        FcmModule.getInstance().exitApp(this);
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        //设置状态栏字体颜色
        StatusBarUtils.setSystemStatusTextColor(true, this);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.llHome));
        listFragment.add(new FragmentViewBinder(CommunityFragment.class, R.id.llCommunity));
        listFragment.add(new FragmentViewBinder(WallpaperFragment.class, R.id.llWallpaper));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.llMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()) {
            case R.id.llHome:
                mDataBinding.ivHome.setImageResource(R.drawable.asy);
                break;
            case R.id.llCommunity:
                mDataBinding.ivCommunity.setImageResource(R.drawable.asq);
                break;
            case R.id.llWallpaper:
                mDataBinding.ivWallpaper.setImageResource(R.drawable.abz);
                break;
            case R.id.llMy:
                mDataBinding.ivMy.setImageResource(R.drawable.awd);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.ashouye);
        mDataBinding.ivCommunity.setImageResource(R.drawable.ashequ);
        mDataBinding.ivWallpaper.setImageResource(R.drawable.abizhi);
        mDataBinding.ivMy.setImageResource(R.drawable.awod);
    }

}